unit FuncionarioRecordFr;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  StdCtrls, DBCtrls, ActnList, Buttons, ExtCtrls, ComCtrls, MainRecordFr, types;

type

  { TFuncionarioRecordFrame }

  TFuncionarioRecordFrame = class(TMainRecordFrame)
    btBuscar: TBitBtn;
    ativo: TDBRadioGroup;
    IdFuncionario: TDBEdit;
    DBEdit10: TDBEdit;
    DBEdit11: TDBEdit;
    DBEdit12: TDBEdit;
    DBEdit13: TDBEdit;
    DBEdit14: TDBEdit;
    DBEdit15: TDBEdit;
    DBEdit16: TDBEdit;
    DBEdit17: TDBEdit;
    DBEdit18: TDBEdit;
    DBEdit19: TDBEdit;
    IdPessoa: TDBEdit;
    DBEdit20: TDBEdit;
    DBEdit21: TDBEdit;
    DBEdit22: TDBEdit;
    DBEdit23: TDBEdit;
    DBEdit24: TDBEdit;
    DBEdit3: TDBEdit;
    DBEdit4: TDBEdit;
    DBEdit5: TDBEdit;
    DBEdit6: TDBEdit;
    DBEdit7: TDBEdit;
    DBEdit8: TDBEdit;
    DBEdit9: TDBEdit;
    DBGroupBox1: TDBGroupBox;
    DBGroupBox2: TDBGroupBox;
    cargo: TDBLookupComboBox;
    DBMemo1: TDBMemo;
    DBGroupBox: TDBGroupBox;
    Label1: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label2: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    PrincipalPageControl: TPageControl;
    Label8: TLabel;
    Label9: TLabel;
    PrincipalTabSheet: TTabSheet;
    EnderecoTabSheet: TTabSheet;
    procedure AlterarActionExecute(Sender: TObject);
    procedure btBuscarClick(Sender: TObject);
    procedure CancelarActionExecute(Sender: TObject);
    procedure FecharActionExecute(Sender: TObject);
    procedure IdPessoaChange(Sender: TObject);
    procedure SalvarActionExecute(Sender: TObject);
    constructor Create(TheOwner: TComponent); override;

  private
    { private declarations }
  public
    { public declarations }
  end;

implementation

uses Initializator, MainFr, FuncionarioDM, PessoaDM, MainDM;

{ TFuncionarioRecordFrame }


procedure TFuncionarioRecordFrame.btBuscarClick(Sender: TObject);
begin
  TheControl.ShowForeignFrame(TMainFrame(PessoaSearchFrame));
end;

procedure TFuncionarioRecordFrame.CancelarActionExecute(Sender: TObject);
begin
  FuncionarioData.PessoaFisicaZQuery.Cancel();
  FuncionarioData.FuncionarioZQuery.Cancel();
  ControlaBotoes();
end;

procedure TFuncionarioRecordFrame.FecharActionExecute(Sender: TObject);
begin
  TheControl.BackFrame();
end;

procedure TFuncionarioRecordFrame.AlterarActionExecute(Sender: TObject);
begin
  FuncionarioData.FuncionarioZQuery.Edit();
  FuncionarioData.PessoaFisicaZQuery.Edit();
  ControlaBotoes();
end;

procedure TFuncionarioRecordFrame.IdPessoaChange(Sender: TObject);
begin
  if (FuncionarioData.DataSetState() in [mdsEditing, mdsInserting]) then begin
    FuncionarioData.FuncionarioZQuery.FieldByName('id_funcionario').AsString :=
      IdPessoa.Text;
    ativo.ItemIndex := 0;
    FuncionarioData.PessoaFisicaZQuery.Open();
    FuncionarioData.PessoaFisicaZQuery.Edit();
  end;
end;

procedure TFuncionarioRecordFrame.SalvarActionExecute(Sender: TObject);
begin
  FuncionarioData.PessoaFisicaZQuery.Post();
  FuncionarioData.FuncionarioZQuery.Post();
  ControlaBotoes();
end;

constructor TFuncionarioRecordFrame.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
  PrincipalPageControl.ActivePage:= EnderecoTabSheet;
end;


initialization
  {$I funcionariorecordfr.lrs}

end.
